package com.fqcar.fqdf.entity;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * 拍照为adapter使用的bean
 *
 * @author 张枭
 * @version V1.0
 * @date 2017/3/23
 * @desc
 */
public class CarPhotoBean implements Parcelable {

    private String path;

    private String url;

    private String showText;

    private boolean cameraPhoto;

    private int defaultPicRes;

    public int getDefaultPicRes() {
        return defaultPicRes;
    }

    public void setDefaultPicRes(int defaultPicRes) {
        this.defaultPicRes = defaultPicRes;
    }

    private CarPhotoBean(Builder builder) {
        setPath(builder.path);
        setUrl(builder.url);
        setShowText(builder.showText);
        setCameraPhoto(builder.cameraPhoto);
        setDefaultPicRes(builder.defaultPicRes);
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getShowText() {
        return showText;
    }

    public void setShowText(String showText) {
        this.showText = showText;
    }

    public boolean isCameraPhoto() {
        return cameraPhoto;
    }

    public void setCameraPhoto(boolean cameraPhoto) {
        this.cameraPhoto = cameraPhoto;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof CarPhotoBean)) return false;

        CarPhotoBean that = (CarPhotoBean) o;

        if (isCameraPhoto() != that.isCameraPhoto()) return false;
        if (getDefaultPicRes() != that.getDefaultPicRes()) return false;
        if (!getPath().equals(that.getPath())) return false;
        return getShowText().equals(that.getShowText());

    }

    @Override
    public int hashCode() {
        int result = getPath().hashCode();
        result = 31 * result + getShowText().hashCode();
        result = 31 * result + (isCameraPhoto() ? 1 : 0);
        result = 31 * result + getDefaultPicRes();
        return result;
    }

    public CarPhotoBean() {
    }

    public static final class Builder {
        private String path;
        private String url;
        private String showText;
        private boolean cameraPhoto;
        private int defaultPicRes;

        public Builder() {
        }

        public Builder withPath(String val) {
            path = val;
            return this;
        }

        public Builder withUrl(String val) {
            url = val;
            return this;
        }

        public Builder withShowText(String val) {
            showText = val;
            return this;
        }

        public Builder withCameraPhoto(boolean val) {
            cameraPhoto = val;
            return this;
        }

        public Builder withDefaultPicRes(int val) {
            defaultPicRes = val;
            return this;
        }

        public CarPhotoBean build() {
            return new CarPhotoBean(this);
        }
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.path);
        dest.writeString(this.url);
        dest.writeString(this.showText);
        dest.writeByte(this.cameraPhoto ? (byte) 1 : (byte) 0);
        dest.writeInt(this.defaultPicRes);
    }

    protected CarPhotoBean(Parcel in) {
        this.path = in.readString();
        this.url = in.readString();
        this.showText = in.readString();
        this.cameraPhoto = in.readByte() != 0;
        this.defaultPicRes = in.readInt();
    }

    public static final Creator<CarPhotoBean> CREATOR = new Creator<CarPhotoBean>() {
        @Override
        public CarPhotoBean createFromParcel(Parcel source) {
            return new CarPhotoBean(source);
        }

        @Override
        public CarPhotoBean[] newArray(int size) {
            return new CarPhotoBean[size];
        }
    };
}
